namespace WiseLink.RDS.Web
{
    using System;
    using System.Web.Mvc;
    using WiseLink.RDS.Model;
    using Telerik.Web.Mvc;
    using System.Collections.Generic;

    public partial class DeviceController : Controller
    {
        private DeviceRepository deviceRepository;
        [GridAction]
        public ActionResult FirstLook()
        {

            return View(new GridModel<DeviceViewModel>
            {
                Data = deviceRepository.GetAllDevices()
            });

        }

        public ActionResult SecondLook()
        {

            return View();
        }
        public DeviceController()
        {
            deviceRepository = new DeviceRepository();
        }

        public JsonResult AddDevice(string deviceSerialNo)
        {
            deviceRepository.AddDevice(deviceSerialNo);
            return Json(string.Format("{0}Succeed", deviceSerialNo));
        }
        public JsonResult SellDevice(int deviceid,int customerid)
        {
            deviceRepository.SellDevice(deviceid,customerid);
            return Json(string.Format("{0}Succeed", customerid));
        }
        public JsonResult InStockDevice(int deviceid)
        {
            deviceRepository.InStockDevice(deviceid);
            return Json(string.Format("{0}Succeed", deviceid));
        }
        public JsonResult RegisterDevice(int deviceid)
        {
            deviceRepository.RegisterDevice(deviceid);
            return Json(string.Format("{0}Succeed", deviceid));
        }
    }
}